package com.tjvib.bean;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class ResBean {
    List<Double> a = new ArrayList<>();
    List<Double> ori_a = new ArrayList<>();
    List<Double> b = new ArrayList<>();
    List<Double> ori_b = new ArrayList<>();
    List<Double> c = new ArrayList<>();
    List<Double> ori_c = new ArrayList<>();

    public ResBean(List<Double> a, List<Double> ori_a, List<Double> b, List<Double> ori_b, List<Double> c, List<Double> ori_c) {
        this.a = a;
        this.ori_a = ori_a;
        this.b = b;
        this.ori_b = ori_b;
        this.c = c;
        this.ori_c = ori_c;
    }

    public ResBean(double[] a, double[] ori_a, double[] b, double[] ori_b, double[] c, double[] ori_c) {
        for(double x : a) this.a.add(x);
        for(double x : ori_a) this.ori_a.add(x);
        for(double x : b) this.b.add(x);
        for(double x : ori_b) this.ori_b.add(x);
        for(double x : c) this.c.add(x);
        for(double x : ori_c) this.ori_c.add(x);
    }

    public List<Double> getA() {
        return a;
    }

    public List<Double> getOri_a() {
        return ori_a;
    }

    public List<Double> getB() {
        return b;
    }

    public List<Double> getOri_b() {
        return ori_b;
    }

    public List<Double> getC() {
        return c;
    }

    public List<Double> getOri_c() {
        return ori_c;
    }

    public static String getString(List<Double> list, String str1, String str2, int d){
        String format = "%." + d + "f";
        StringBuilder res = new StringBuilder(str1);
        for (int i = 0; i < list.size(); i++) {
            if(d == 0) res.append(Math.round(list.get(i)));
            else res.append(String.format(format, list.get(i)));
            if (i != list.size() - 1) res.append(", ");
        }
        res.append(str2);
        return res.toString();
    }
}
